#!/usr/bin/env python
import sys
import class_set
import helper
from sets import Set

class FeedRecommendationReducer(helper.ReducerHelper):

    def processor(self, key, lst):
        feed = Set()
        user = Set()
        for e in lst:
            if class_set.RecomTag.isMumber(e):
                recom_tag = class_set.RecomTag('')
                recom_tag.init(e)
                recom_tag.setIsResult(True)
                feed.add(recom_tag)
            else:
                user.add(e)
        for u in user:
            for f in feed:
                left = self.join(u, f.getRelatedId())
                f.setRelatedId(key)
                right = f
                self.allocator(left, right)

def main():
    fr = FeedRecommendationReducer()
    fr.reducer()

if __name__ == '__main__':
    main()









